/**
  ******************************************************************************
  * @file           : linear_module.c
  * @author         : Mark Xiang
  * @brief          : brief
  ******************************************************************************
  * @attention
  *
  ******************************************************************************
  */

/* ------------------------------ Includes ------------------------------ */

#include "linear_module.h"

/* ------------------------------ Defines ------------------------------ */

/* ------------------------------ Private Function Declarations ------------------------------ */

/* ------------------------------ Public Function Declarations ------------------------------ */

static void Init(LinearModule_t *module, LinearModuleInit_t init_struct);
static void SetVel(LinearModule_t *module, float vel);
static void Stop(LinearModule_t *module);
static void ResetPos(LinearModule_t *module);
static float GetWorkSpace(LinearModule_t *module);

/* ------------------------------ Variable Declarations ------------------------------ */

/* ------------------------------ Private ------------------------------ */

/* ------------------------------ Public ------------------------------ */

static void Init(LinearModule_t *module, LinearModuleInit_t init_struct)
{
  /* 初始化pid结构体，无增量和输出限制 */
  Pid.Init( &module->vel_pid_controller,
            init_struct.pid_controller_kp,
            init_struct.pid_controller_ki,
            init_struct.pid_controller_kd,
            0, 0);

  /* GPIO引脚 */
  module->nENBL_PORT    = init_struct.nENBL_PORT;
  module->nENBL_Pin     = init_struct.nENBL_Pin;
  module->MODE0_PORT    = init_struct.MODE0_PORT;
  module->MODE0_Pin     = init_struct.MODE0_Pin;
  module->MODE1_PORT    = init_struct.MODE1_PORT;
  module->MODE1_Pin     = init_struct.MODE1_Pin;
  module->MODE2_PORT    = init_struct.MODE2_PORT;
  module->MODE2_Pin     = init_struct.MODE2_Pin;
  module->MODE3_PORT    = init_struct.MODE3_PORT;
  module->MODE3_Pin     = init_struct.MODE3_Pin;

  module->nFAULT_PORT   = init_struct.nFAULT_PORT;
  module->nFAULT_Pin    = init_struct.nFAULT_Pin;
  module->MIN_LIM_PORT  = init_struct.MIN_LIM_PORT;
  module->MIN_LIM_Pin   = init_struct.MIN_LIM_Pin;
  module->MAX_LIM_PORT  = init_struct.MAX_LIM_PORT;
  module->MAX_LIM_Pin   = init_struct.MAX_LIM_Pin;

  /* 定时器通道 */
  module->p_htim        = init_struct.p_htim;
  module->channel       = init_struct.channel;
}

static void SetVel(LinearModule_t *module, float vel)
{

}

/* ------------------------------ Manager Declaration ------------------------------ */
